package cn.anecansaitin.whimsy.common.extension.comboSystem;

import net.minecraft.world.entity.player.Player;

public interface INormalSkill extends ISkill {
    @Override
    default boolean execute(int skillTick, Player player, ExtraData extra) {
        if (skillTick < precastTick()) {
            if (skillTick <= 0) {
                prePrecast(player, extra);
            }

            precast(skillTick, player, extra);
            return false;
        } else if (skillTick < precastTick() + activeTick()) {
            if (skillTick == precastTick()) {
                preActive(player, extra);
            }

            active(skillTick - precastTick(), player, extra);
            return false;
        } else if (skillTick < precastTick() + activeTick() + backswingTick()) {
            if (skillTick == precastTick() + activeTick()) {
                preBackswing(player, extra);
            }

            backswing(skillTick - precastTick() - activeTick(), player, extra);
            return false;
        } else {
            finish(player, extra);
            return true;
        }
    }

    /**
     * @return 前摇的持续时间
     */
    int precastTick();

    /**
     * @return 技能释放的持续时间
     */
    int activeTick();

    /**
     * @return 后摇的持续时间
     */
    int backswingTick();

    /**
     * 前摇开始前
     */
    void prePrecast(Player player, ExtraData extra);

    /**
     * 前摇执行期间
     */
    void precast(int skillTick, Player player, ExtraData extra);

    /**
     * 技能执行前
     */
    void preActive(Player player, ExtraData extra);

    /**
     * 技能执行期间
     */
    void active(int skillTick, Player player, ExtraData extra);

    /**
     * 后摇开始前
     */
    void preBackswing(Player player, ExtraData extra);

    /**
     * 后摇执行期间
     */
    void backswing(int skillTick, Player player, ExtraData extra);

    /**
     * 完全结束后
     */
    void finish(Player player, ExtraData extra);
}
